﻿using MediatR;
using S.Services.SheepMale.Domain.PurchaseSales;
using S.Services.SheepMale.Infrastructure;
using S.Services.SheepMale.Read.Api.Application.ReadCommand.ReadSheepMaleCommand;

namespace S.Services.SheepMale.Read.Api.Application.ReadCommandHandler.ReadSheepMaleCommandHandler
{
    public class PruchaseGetCommandHandler : IRequestHandler<PruchaseGetCommand, EntityPurchase>
    {
        private readonly IRepository<EntityPurchase> repository;

        public PruchaseGetCommandHandler(IRepository<EntityPurchase> repository)
        {
            this.repository = repository;
        }

        public async Task<EntityPurchase> Handle(PruchaseGetCommand request, CancellationToken cancellationToken)
        {
            return await repository.GetAsync(request.purId);
        }
    }
}
